/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.p2psimulator.entity.overlaynetwork.routingtable;

import java.util.HashMap;
import java.util.Map;
import org.p2psimulator.entity.Id;
import org.p2psimulator.entity.overlaynetwork.structures.ChordFingerRing;
import org.p2psimulator.entity.overlaynetwork.structures.StormWitnessRing;

/**
 * Routing table for inter-ring connections
 * @author Amorim
 */
public class StormRoutingTable extends ChordRoutingTable<Id> {

    private Map<Id, StormWitnessRing> witnessesRings;
    public StormRoutingTable(int M, Id owner) {
        super(M, new ChordFingerRing(M), owner);
        witnessesRings = new HashMap<Id, StormWitnessRing>();
    }
    

    public Map<Id, StormWitnessRing> getWitnessesRings() {
        return witnessesRings;
    }

    public void setWitnessesRings(Map<Id, StormWitnessRing> witnessesRings) {
        this.witnessesRings = witnessesRings;
    }
    public StormWitnessRing getWitnessRing(Id referredServentId){
        return witnessesRings.get(referredServentId);
    }

    @Override
    public boolean contains(Id key){
        return witnessesRings.containsKey(key);
    }

    @Override
    public void clear() {
        witnessesRings.clear();
    }

    @Override
    public boolean deletePeer(Id peer) {
        return witnessesRings.remove(peer)!=null;
    }

    @Override
    public void insertNode(Id peer, Id value) {
        witnessesRings.put(peer,new StormWitnessRing(M));
    }

    public void insertNode(Id peer, StormWitnessRing value) {
        witnessesRings.put(peer,value);
    }
}
